package cn.tedu.collection;


//import cn.tedu.seri.Student;
import org.junit.jupiter.api.Test;

import java.util.Arrays;

/*本类用于集合前的一些测试*/
public class Demo {
    //单元测试方法:public + void + 没有参数 + @Test
    //1.完成单元测试方法saveStudent
    @Test
    public void saveStudent(){
        //3.创建数组,用来存放Student类的3个对象s1 s2 s3,并打印查看
        Student s1 = new Student("张三",3,'男');
        Student s2 = new Student("李四",4,'女');
        Student s3 = new Student("王五",5,'男');

       /* Student[] s = new Student[3]; //自定义的引用类型数组也可以通过Arrays.toString打印出来
        s[0] = s1; //动态创建 引用类型的数组
        s[1] = s2;
        s[2] = s3;*/
//      Student[] s = new Student[]{s1,s2,s3};
        Student[] s ={s1,s2,s3};

        System.out.println(Arrays.toString(s));
    }

    @Test
    public void testArray(){
        int[] a = {1,2,3};
        int[] a2 = new int[3];
        a2[0] = 1; //数组每个位置上的值默认是0,但是都可以重新存值和赋值
        a2[1] = 2; //存值//1,2,3替代s1,s2,s3
        a2[2] = 3;
        System.out.println(Arrays.toString(a));//1)非cha[]需要使用Arrays.toString方法,2)toString重写了Object方法,打印的不是地址值而是数组的具体的值,
        System.out.println(Arrays.toString(a2));
    }

}
